""" -*- coding: utf-8 -*-
 @Time    : 2019/1/24 21:41
 @Author  : 木鱼
 @File    : app.py
 @Software: PyCharm
"""
from flask import Flask as _Flask
from flask.json import JSONEncoder as _JSONEncoder
from datetime import date


# def register_blueprints(app):
#     from app.api.v1 import create_blueprint
#     app.register_blueprint(create_blueprint(), url_prefix='/v1')
#
#
class JSONEncoder(_JSONEncoder):
    def default(self, o):
        if hasattr(o, 'keys') and hasattr(o, '__getitem__'):
            return dict(o)
        if isinstance(o, date):
            return o.strftime('%Y-%m-%d')
        raise {}
        # 占位
        # raise ServerError()


class Flask(_Flask):
    json_encoder = JSONEncoder
